package com.app.designpattern.structural.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * USER: zjw
 * DATA: 2019/4/24 0024
 * TIME: 上午 10:47
 */
public class CatalogCursor extends CataLoagComponte {
    List<CataLoagComponte> items = new ArrayList<>();
    private String name;

    public CatalogCursor(String name) {
        this.name = name;
    }

    @Override
    public void add(CataLoagComponte cataLoagComponte) {
        items.add(cataLoagComponte);
    }

    @Override
    public void remove(CataLoagComponte cataLoagComponte) {
        items.remove(cataLoagComponte);
    }

    @Override
    public String getName(CataLoagComponte cataLoagComponte) {
        return this.name;
    }

    @Override
    public void prit() {
        for (CataLoagComponte item : items) {
            item.prit();
        }
    }
}
